import request from '@/utils/request'
import type {
  Login,
  UserDto,
  AddScenic,
  UpdateScenic,
  DynamicDto,
  updatDynamicStatus
} from '@/types'
// 上传文件
export const upload = (data: FormData) => {
  return request<any>('/upload/2', 'POST', data)
}

// 删除图片
export const deleteImage = (imgs: string[]) => {
  return request<any>('/upload', 'DELETE', imgs)
}

// 登录
export const login = (data: Login) => {
  return request<any>('/admin/login', 'POST', data)
}

// 获取统计数据
export const getStatistics = () => {
  return request<any>('/admin/statistics')
}

// 获取用户列表
export const getUserList = (data: UserDto) => {
  return request<any>('/admin/user/list', 'POST', data)
}

// 用户禁言/解禁
export const banUser = (id: number) => {
  return request<any>(`/admin/user/banned/${id}`, 'PUT')
}

// 获取景区列表
export const getScenicList = (data: ScenicDto) => {
  return request<any>('/admin/scenic/list', 'POST', data)
}

// 获取景区详情
export const getScenicDetail = (id: number) => {
  return request<any>(`/admin/scenic/${id}`)
}

// 添加景区
export const addScenic = (data: AddScenic) => {
  return request<any>('/admin/scenic', 'POST', data)
}

// 修改景区
export const updateScenic = (data: UpdateScenic) => {
  return request<any>(`/admin/scenic`, 'PUT', data)
}

// 删除景区
export const deleteScenic = (id: number) => {
  return request<any>(`/admin/scenic/${id}`, 'DELETE')
}

// 获取动态列表
export const getDynamicList = (data: DynamicDto) => {
  return request<any>('/admin/community/list', 'POST', data)
}

// 获取动态详情
export const getDynamicDetail = (id: number) => {
  return request<any>(`/admin/community/${id}`)
}

// 审核动态
export const auditDynamic = (data: updatDynamicStatus) => {
  return request<any>('/admin/community', 'PUT', data)
}
